<html>
<head><meta charset="utf-8"><title>match as expression parsing error · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html">match as expression parsing error</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="203466780"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203466780" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203466780">(Jul 10 2020 at 03:44)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">foo</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="kt">bool</span> <span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="k">match</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="kc">true</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="o">&amp;&amp;</span><span class="w"> </span><span class="kc">false</span><span class="w"></span>
<span class="w">  </span><span class="c1">//                      ^ expected expression, found `&amp;&amp;`</span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>


<p>This example works with parentheses around the <code>match</code> expression. I guess this is due to a parser ambiguity between expressions and statements?</p>



<a name="203467263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203467263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> kennytm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203467263">(Jul 10 2020 at 03:57)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">foo</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="kp">&amp;</span><span class="nb">&#39;static</span><span class="w"> </span><span class="o">&amp;</span><span class="nb">&#39;static</span><span class="w"> </span><span class="kt">bool</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">match</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="o">&amp;&amp;</span><span class="w"> </span><span class="p">(</span><span class="kc">false</span><span class="p">)</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="203468241"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203468241" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203468241">(Jul 10 2020 at 04:22)</a>:</h4>
<p>I guess that the parentheses around <code>false</code> are needed there to distinguish it from the (nonsense) three statements</p>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">foo</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="kt">bool</span> <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">match</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="o">&amp;&amp;</span><span class="w"></span>
<span class="w">    </span><span class="kc">false</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="203468295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203468295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203468295">(Jul 10 2020 at 04:24)</a>:</h4>
<p>What are the rules around statement splitting? Are they written down or discussed anywhere?</p>



<a name="203470328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203470328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203470328">(Jul 10 2020 at 05:19)</a>:</h4>
<p>wait what</p>



<a name="203470331"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203470331" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203470331">(Jul 10 2020 at 05:19)</a>:</h4>
<p><code>&amp;&amp;false</code> should be a valid expression</p>



<a name="203470333"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203470333" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203470333">(Jul 10 2020 at 05:19)</a>:</h4>
<p>(of type <code>&amp;&amp;bool</code>)</p>



<a name="203472073"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203472073" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203472073">(Jul 10 2020 at 06:02)</a>:</h4>
<p>It is, but the issue here seems to be that parsing is ambiguous - there are multiple parse trees yielding the same token sequence</p>



<a name="203577340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577340">(Jul 11 2020 at 03:05)</a>:</h4>
<p><span class="user-mention" data-user-id="271719">@Mario Carneiro</span> but the <code>rustc</code> parser doesn't really understand ambiguity</p>



<a name="203577347"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577347" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577347">(Jul 11 2020 at 03:05)</a>:</h4>
<p>it's largely LL(k) for small k (4? not sure)</p>



<a name="203577391"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577391" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577391">(Jul 11 2020 at 03:06)</a>:</h4>
<p>Right; of course the parser is deterministic, so something has to come out at the end, but the basic CFG style presentation of the grammar will contain impossible parses as a result</p>



<a name="203577392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577392">(Jul 11 2020 at 03:06)</a>:</h4>
<p>I mean that the error is nonsensical because <code>&amp;&amp;</code> can start an expression</p>



<a name="203577393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577393">(Jul 11 2020 at 03:06)</a>:</h4>
<p>shortest example I can make: <code>fn main() { {} &amp;&amp; false }</code></p>



<a name="203577394"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577394" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577394">(Jul 11 2020 at 03:06)</a>:</h4>
<p>well, <code>false</code> could be any expression</p>



<a name="203577398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577398">(Jul 11 2020 at 03:07)</a>:</h4>
<div class="codehilite"><pre><span></span><code>error: expected expression, found `&amp;&amp;`
 --&gt; src/main.rs:1:16
  |
1 | fn main() { {} &amp;&amp; false }
  |             -- ^^ expected expression
  |             |
  |             help: parentheses are required to parse this as an expression: `({})`
</code></pre></div>



<a name="203577400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577400">(Jul 11 2020 at 03:07)</a>:</h4>
<p>oh, that's more help than I got</p>



<a name="203577402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577402">(Jul 11 2020 at 03:07)</a>:</h4>
<p>I wonder if this error comes from something that doesn't actually correctly implement a heuristic for "what tokens can start an expression"</p>



<a name="203577446"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577446" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577446">(Jul 11 2020 at 03:08)</a>:</h4>
<p>My interpretation of the error is that it has decided that it is three statements <code>{}</code> <code>&amp;&amp;</code> <code>false</code> and the middle one is not well formed</p>



<a name="203577447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577447">(Jul 11 2020 at 03:08)</a>:</h4>
<p>or it's intentional, but in that case... yeah it behaves correctly with <code>&amp; &amp; false</code></p>



<a name="203577448"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577448" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577448">(Jul 11 2020 at 03:08)</a>:</h4>
<p><span class="user-mention" data-user-id="271719">@Mario Carneiro</span> nope, that should be impossible</p>



<a name="203577451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577451">(Jul 11 2020 at 03:08)</a>:</h4>
<p>that normally happens if you write <code>{} expr</code> is that it's equivalent to having a semicolon between them</p>



<a name="203577458"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577458" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577458">(Jul 11 2020 at 03:09)</a>:</h4>
<p><code>{} &amp;&amp;false</code> should work exactly like <code>{} &amp; &amp;false</code></p>



<a name="203577463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577463">(Jul 11 2020 at 03:09)</a>:</h4>
<p>and <code>&amp;&amp;false</code>, when parsed as an expression, does parse like <code>&amp; &amp;false</code></p>



<a name="203577465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577465">(Jul 11 2020 at 03:09)</a>:</h4>
<p>I guess there must be some special casing to turn <code>&amp;&amp;</code> into <code>&amp;</code> <code>&amp;</code>?</p>



<a name="203577466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577466">(Jul 11 2020 at 03:09)</a>:</h4>
<p>so it must be <em>something else</em> that is checking "can this token start an expression" and produce the confusing error</p>



<a name="203577468"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577468" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577468">(Jul 11 2020 at 03:09)</a>:</h4>
<p>composite tokens semi-automatically decompose</p>



<a name="203577508"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577508" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577508">(Jul 11 2020 at 03:10)</a>:</h4>
<p>ideally we'd have the <code>libproc_macro</code> token model which has individual punctuation characters with "is this adjoined to the next punctuation character" flags</p>



<a name="203577509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577509">(Jul 11 2020 at 03:10)</a>:</h4>
<p>anyway I might be able to find the problem code</p>



<a name="203577515"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577515" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577515">(Jul 11 2020 at 03:11)</a>:</h4>
<p>I mean it's true that <code>&amp;&amp;</code> can't start an expression, expressions have to start with <code>&amp;</code> <code>&amp;</code> so it looks like the token decomposition didn't happen or didn't happen at the right time</p>



<a name="203577561"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577561" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577561">(Jul 11 2020 at 03:12)</a>:</h4>
<p>but <code>&amp;&amp;false</code> is a valid expression</p>



<a name="203577562"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577562" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577562">(Jul 11 2020 at 03:12)</a>:</h4>
<p><del>try it!</del> nvm I think I misread what you said, <code>&amp;</code> <code>&amp;</code> doesn't look very different from <code>&amp; &amp;</code> in dark mode</p>



<a name="203577570"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577570" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577570">(Jul 11 2020 at 03:13)</a>:</h4>
<p>okay I think I found it and judging by the looks of this code it <em>is</em> intentional (to some extent?) but the error message doesn't get across what it means</p>



<a name="203577621"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577621" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577621">(Jul 11 2020 at 03:14)</a>:</h4>
<p>okay <code>should_continue_as_assoc_expr</code> is confusing me further but it explicitly lists <code>&amp;&amp;</code> so I assume this is very much intentional</p>



<a name="203577632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577632">(Jul 11 2020 at 03:15)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/master/src/librustc_parse/parser/expr.rs#L293-L299">https://github.com/rust-lang/rust/blob/master/src/librustc_parse/parser/expr.rs#L293-L299</a></p>



<a name="203577633"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577633" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577633">(Jul 11 2020 at 03:15)</a>:</h4>
<p>I notice also that <code>fn main() { {} &amp;&amp; false }</code> complains about the return type being <code>()</code> instead of <code>bool</code> so it has decided that <code>false</code> is a statement on its own</p>



<a name="203577634"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577634" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577634">(Jul 11 2020 at 03:15)</a>:</h4>
<p>if it produced an error during parsing, it's likely the AST <del>is broken</del> doesn't match the source too well</p>



<a name="203577677"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577677" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577677">(Jul 11 2020 at 03:16)</a>:</h4>
<p>presumably threw away the <code>&amp;&amp;</code> and kept going</p>



<a name="203577691"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577691" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577691">(Jul 11 2020 at 03:17)</a>:</h4>
<p>Where is that <code>ambiguous_block_expr_parse</code> used later?</p>



<a name="203577730"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577730" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577730">(Jul 11 2020 at 03:18)</a>:</h4>
<p>ughhhh apparently this sort of thing was introduced for diagnostics <a href="https://github.com/rust-lang/rust/pull/60188">https://github.com/rust-lang/rust/pull/60188</a></p>



<a name="203577740"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577740" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577740">(Jul 11 2020 at 03:19)</a>:</h4>
<p><span class="user-mention" data-user-id="271719">@Mario Carneiro</span> oh this behavior might actually be a bug</p>



<a name="203577741"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577741" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577741">(Jul 11 2020 at 03:19)</a>:</h4>
<p><code>{} &amp;&amp; 0</code> does what one might expect</p>



<a name="203577751"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577751" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577751">(Jul 11 2020 at 03:20)</a>:</h4>
<p>Is it because <code>false</code> is a <code>is_reserved_ident()</code>?</p>



<a name="203577791"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577791" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577791">(Jul 11 2020 at 03:20)</a>:</h4>
<p>yeah, it's a keyword</p>



<a name="203577794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577794">(Jul 11 2020 at 03:20)</a>:</h4>
<p><span class="user-mention" data-user-id="119031">@Esteban Küber</span> is the intention here to look for <em>control-flow</em> keywords? <a href="https://github.com/rust-lang/rust/blob/daecab3a784f28082df90cebb204998051f3557d/src/librustc_parse/parser/expr.rs#L300-L302">https://github.com/rust-lang/rust/blob/daecab3a784f28082df90cebb204998051f3557d/src/librustc_parse/parser/expr.rs#L300-L302</a></p>



<a name="203577797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577797">(Jul 11 2020 at 03:20)</a>:</h4>
<p>which also explains why <code>&amp;&amp;(false)</code> works</p>



<a name="203577806"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577806" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577806">(Jul 11 2020 at 03:20)</a>:</h4>
<p><span class="user-mention" data-user-id="119031">@Esteban Küber</span> because there's way more keywords in Rust and not all of them have the same properties</p>



<a name="203577883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577883">(Jul 11 2020 at 03:23)</a>:</h4>
<p>also left a comment on the PR but maybe a new issue should be created <a href="https://github.com/rust-lang/rust/pull/61500#discussion_r453148523">https://github.com/rust-lang/rust/pull/61500#discussion_r453148523</a></p>



<a name="203577887"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577887" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577887">(Jul 11 2020 at 03:23)</a>:</h4>
<p>it's unclear from the code what the effect is but this definitely seems to be the condition getting triggered</p>



<a name="203577934"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577934" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577934">(Jul 11 2020 at 03:24)</a>:</h4>
<p>also "expected expression, found <code>...</code>" looks very wrong when the token in question can actually start an expression</p>



<a name="203577936"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577936" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577936">(Jul 11 2020 at 03:24)</a>:</h4>
<p>but I guess it makes sense for something like <code>{} / 2</code>, where <code>/2</code> is not a valid expression</p>



<a name="203577937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577937">(Jul 11 2020 at 03:24)</a>:</h4>
<p>Note that this code, mentioned in the comment, also triggers the same <code>expected expression, found &amp;&amp;</code> error</p>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="kt">bool</span> <span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="k">if</span><span class="w"> </span><span class="kc">true</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="kc">true</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="kc">true</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="o">&amp;&amp;</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="kc">false</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="kc">false</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="kc">false</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="203577949"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577949" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577949">(Jul 11 2020 at 03:24)</a>:</h4>
<p>huh I wonder if the "Fix regression" PR actually introduced a new bug</p>



<a name="203577955"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577955" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577955">(Jul 11 2020 at 03:25)</a>:</h4>
<p>it's not clear from the comment text if it is intended to show a known good case or a known bad case</p>



<a name="203577973"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577973" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577973">(Jul 11 2020 at 03:25)</a>:</h4>
<p>oh the test shows what it's trying to prevent</p>



<a name="203577977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203577977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203577977">(Jul 11 2020 at 03:25)</a>:</h4>
<p><code>&amp;&amp;A =&gt; {} &amp;&amp;B =&gt; {}</code> in a <code>match</code></p>



<a name="203578014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203578014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203578014">(Jul 11 2020 at 03:26)</a>:</h4>
<p>specifically the middle interaction</p>



<a name="203578100"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203578100" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203578100">(Jul 11 2020 at 03:29)</a>:</h4>
<p>oh but <code>&amp;&amp;true =&gt; {} &amp;&amp;false =&gt; {}</code> is also valid in the same context</p>



<a name="203578157"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203578157" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203578157">(Jul 11 2020 at 03:30)</a>:</h4>
<p>as it should be. nobody is suggesting that <code>{} &amp;&amp; ...</code> actually parse as a logical AND expression I don't think</p>



<a name="203578171"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203578171" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203578171">(Jul 11 2020 at 03:30)</a>:</h4>
<p>(well, my first post was suggesting that but I've since repented)</p>



<a name="203578181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203578181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203578181">(Jul 11 2020 at 03:31)</a>:</h4>
<p>what case does <code>{} &amp; false</code> even hit?</p>



<a name="203578183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203578183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203578183">(Jul 11 2020 at 03:31)</a>:</h4>
<p>maybe that's what we're missing</p>



<a name="203578223"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203578223" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203578223">(Jul 11 2020 at 03:32)</a>:</h4>
<p>presumably <code>can_continue_expr_unambiguously</code>?</p>



<a name="203578226"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203578226" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203578226">(Jul 11 2020 at 03:32)</a>:</h4>
<p>ah! <a href="https://github.com/rust-lang/rust/blob/daecab3a784f28082df90cebb204998051f3557d/src/librustc_parse/parser/expr.rs#L308">https://github.com/rust-lang/rust/blob/daecab3a784f28082df90cebb204998051f3557d/src/librustc_parse/parser/expr.rs#L308</a></p>



<a name="203578232"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203578232" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203578232">(Jul 11 2020 at 03:32)</a>:</h4>
<p>the first time I read this I missed the <code>!</code></p>



<a name="203578239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203578239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203578239">(Jul 11 2020 at 03:32)</a>:</h4>
<p>so it's skipping erroring if it may be ambiguous</p>



<a name="203578244"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203578244" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203578244">(Jul 11 2020 at 03:33)</a>:</h4>
<p>so the definition of <code>can_continue_expr_unambiguously</code> is probably wrong</p>



<a name="203578257"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203578257" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203578257">(Jul 11 2020 at 03:33)</a>:</h4>
<p><span class="user-mention" data-user-id="271719">@Mario Carneiro</span> oh another fun trick is using godbolt to show that code that compiled on some older version has since regressed</p>



<a name="203578258"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203578258" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203578258">(Jul 11 2020 at 03:33)</a>:</h4>
<p>lemme go do that</p>



<a name="203578259"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203578259" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203578259">(Jul 11 2020 at 03:33)</a>:</h4>
<p>and then open an issue, assuming you haven't already</p>



<a name="203578303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203578303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203578303">(Jul 11 2020 at 03:34)</a>:</h4>
<p>I haven't (I'm still not quite sure what the "right" answer is in these examples)</p>



<a name="203578310"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203578310" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203578310">(Jul 11 2020 at 03:34)</a>:</h4>
<p><code>&amp;&amp;</code> parsing like <code>&amp; &amp;</code> does</p>



<a name="203578317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203578317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203578317">(Jul 11 2020 at 03:34)</a>:</h4>
<p>well, <code>} &amp;&amp;</code> specifically</p>



<a name="203578389"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203578389" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203578389">(Jul 11 2020 at 03:36)</a>:</h4>
<p>I think the parsing of <code>{} &amp; false</code> is right though?</p>



<a name="203578396"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203578396" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203578396">(Jul 11 2020 at 03:37)</a>:</h4>
<p>Because it cannot continue unambiguously, it stops the expr at the end of the block and continues as a separate statement</p>



<a name="203578400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203578400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203578400">(Jul 11 2020 at 03:37)</a>:</h4>
<p><code>&amp;&amp;</code> should do the same</p>



<a name="203578402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203578402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203578402">(Jul 11 2020 at 03:37)</a>:</h4>
<p>it's just a broken heuristic</p>



<a name="203578405"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203578405" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203578405">(Jul 11 2020 at 03:37)</a>:</h4>
<p><a href="https://godbolt.org/z/MTb489">https://godbolt.org/z/MTb489</a></p>



<a name="203578446"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203578446" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203578446">(Jul 11 2020 at 03:38)</a>:</h4>
<p>yeah this is a stable-to-stable regression. brb writing bug report :D</p>



<a name="203579024"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203579024" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203579024">(Jul 11 2020 at 03:56)</a>:</h4>
<p><span class="user-mention" data-user-id="271719">@Mario Carneiro</span> sorry, got distracted <a href="https://github.com/rust-lang/rust/issues/74233">https://github.com/rust-lang/rust/issues/74233</a></p>



<a name="203579037"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203579037" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203579037">(Jul 11 2020 at 03:56)</a>:</h4>
<p>what's your GitHub @? you should get props for hitting this</p>



<a name="203579053"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203579053" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203579053">(Jul 11 2020 at 03:57)</a>:</h4>
<p>(and asking about it instead of tweaking the code and moving on :P)</p>



<a name="203579683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203579683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203579683">(Jul 11 2020 at 04:18)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> that code you linked is supposed to not change parse behavior, only keep extra info around in case we encounter likely expressions missing parens. I'll read this thread later in more detail.</p>



<a name="203579777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203579777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203579777">(Jul 11 2020 at 04:20)</a>:</h4>
<p><span class="user-mention" data-user-id="119031">@Esteban Küber</span> there were some false starts, mostly due to me looking in the wrong part of the code. the fix should just be removing one case from <code>can_continue_expr_unambiguously</code> (the <code>LAnd</code> aka <code>&amp;&amp;</code> one, which is actually as ambiguous as <code>&amp;</code>). it might even remove the need for <a href="https://github.com/rust-lang/rust/issues/61500">#61500</a> (i.e. I think you may have worked around the regression using a heuristic when the problem was elsewhere)</p>



<a name="203579779"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203579779" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203579779">(Jul 11 2020 at 04:20)</a>:</h4>
<p><span class="user-mention" data-user-id="119031">@Esteban Küber</span> the important stuff is detailed in my report, <a href="https://github.com/rust-lang/rust/issues/74233">#74233</a></p>



<a name="203579869"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203579869" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203579869">(Jul 11 2020 at 04:23)</a>:</h4>
<p>anyway, while making a PR should be easy (just remove the <code>LAnd |</code> line), it might be possible to cleanup the other heuristics taking into account that multi-character punctuation can have different interpretations in different positions</p>



<a name="203579918"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203579918" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203579918">(Jul 11 2020 at 04:24)</a>:</h4>
<p>and also the thing about <code>+</code> not being a valid prefix operator in Rust, but that's neither here nor there</p>



<a name="203579932"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203579932" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203579932">(Jul 11 2020 at 04:25)</a>:</h4>
<p><span class="user-mention" data-user-id="119031">@Esteban Küber</span> as to why it changed behavior: you're emitting an error that you thought was replacing a different error, but the conditions for emitting the error are incorrect in at least one case and it's emitted even though previously there was no error</p>



<a name="203579939"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203579939" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203579939">(Jul 11 2020 at 04:26)</a>:</h4>
<p>I'm surprised there isn't a different heuristic for "can this start an expression" that you could've used</p>



<a name="203579978"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203579978" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203579978">(Jul 11 2020 at 04:26)</a>:</h4>
<p>or maybe there is but it's annoying to use because of tokens etc.</p>



<a name="203708052"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203708052" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203708052">(Jul 13 2020 at 12:24)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> I am @digama0</p>



<a name="203708655"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/match%20as%20expression%20parsing%20error/near/203708655" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/match.20as.20expression.20parsing.20error.html#203708655">(Jul 13 2020 at 12:31)</a>:</h4>
<p><span class="user-mention" data-user-id="271719">@Mario Carneiro</span> thanks!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>